<template>
	<view class="">
		<view class="body p-20 f f-a-c f-w-w">
			<view v-for="(item,index) in list" :key="index" class="item b-r-20 b-f p-15">
				<view class="topItem">
					<image :src="item.examination.cover" class="img" mode=""></image>
				</view>
				<view class="name">
					{{item.examination.name}}
				</view>
				<view class="cenTou f f-a-c ">
					<image :src="userinfo.avatar" class="avaer" mode=""></image>
					<view class="time">
						通关时间:{{item.duration}}s
					</view>
				</view>
				<view @click="customs(item)" class="examine">
					查看
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				page: 1,
				total: 0,
				userinfo: uni.getStorageSync('userinfo')
			}
		},
		onReachBottom() {
			if (this.list.length == this.total) {
				return
			}
			console.log('123456');
			this.page++
			this.initList()
		},
		onLoad() {
			this.page = 1
			this.list = []
			this.initList()
		},
		methods: {
			async initList() {
				let n = await this.$api.Examinations({
					page: this.page
				})
				this.total = n.data.total
				this.list = [...this.list, ...n.data.data]

			},
			// 跳转到记录
			customs(item) {
				uni.navigateTo({
					url: '/pages/ReadingParty/Record?obj=' + JSON.stringify(item.levels)
				})
			}
		}
	}
</script>

<style>
	page {
		background-color: #f6f6f6;
	}
</style>
<style lang="scss" scoped>
	.examine {
		width: 100%;
		height: 64rpx;
		line-height: 64rpx;
		border: 2rpx solid #009d85;
		border-radius: 34rpx;
		font-size: 26rpx;
		font-family: PingFang SC, PingFang SC-Regular;
		font-weight: 400;
		text-align: center;
		color: #009d85;
	}

	.cenTou {
		margin: 10rpx 0;
		margin-bottom: 20rpx;

		.avaer {
			width: 48rpx;
			height: 48rpx;
			border-radius: 50%;
			margin-right: 15rpx;
		}

		.time {
			font-size: 26rpx;
			font-family: PingFang SC, PingFang SC-Medium;
			font-weight: 500;
			color: #666666;
		}
	}

	.item {
		margin-bottom: 25rpx;
		width: 48%;
		margin-right: 2%;
		padding-bottom: 30rpx;

		:nth-child(2n) {
			margin-right: 0;
		}
	}

	.name {
		margin: 10rpx 0;
		font-size: 28rpx;
		font-family: PingFang SC, PingFang SC-Bold;
		font-weight: 700;
		color: #1a1a1a;
	}

	.topItem {
		width: 100%;
		height: 300rpx;
		background: #f6f6f6;

		.img {
			width: 90%;
			height: 90%;
			margin-top: 47%;
			margin-left: 50%;
			transform: translate(-50%, -50%);
		}
	}
</style>